﻿using LzmaHelper;
using System.Collections;
using UnityEngine;

namespace MyAssetBundles {
    public class CompressFolderProgress : FolderProgress {
        protected override void ShowProgress ()
        {
            string info = string.Format("process number: {0}k, total number: {1}k, progress: {2}%", target.processNum / 1000, target.totalNum / 1000, target.progress * 100);
            ShowProgress("Compress", info);
        }
    }

    public class CompressFolder : CoderFolder, IFolder {
        public void Generate (string path, IFolderProgress progress)
        {
            SetProgress(progress, _inTotalSize);
            LzmaParams myParams = CreateCoderParams(path);
            AddAutoDeleteFile(myParams.inputPath);
            LzmaCoder.Compress(ref myParams);
            if (myParams.error != null)
            {
                Debug.Log("Error: Coder");
            }
        }

        public override void SetProgress (long inSize, long outSize)
        {
            _outTotalSize = outSize;
            SetProcessNum(inSize);
        }
    }
}

